$(function(){
        var productId;
        // 获取传进来的参数？...
        var id=window.location.search;
        // console.log(id);
        var productid=id.split("=")[1];
        // console.log(productid);
        
        $.ajax({
            url:'http://193.112.55.79:9090/api/getdiscountproduct',
            
            dataType:'json',
            data:{"productid":productid},
            success:function(res){
                console.log(res);
                var xx=template("DisList",res);
                // console.log(xx);
                $('.dis_content').html(xx);
                var comm=template("CommList",res);
                $('.dis_commend').html(comm);
            }
        })
        
        // 评论
        $('.dis_commend').on('click','.ctrl input',function(){
            var val=$('textarea').val();
            if(!$.trim(val)){
                alert("评论的内容不能为空！！！");
                return;
            }
            // alert(a);
            console.log($('ul'));
            var curDate=getNowFormatDate();
            console.log(curDate);
           
            $('ul').prepend($('<li>'+val+'<div><span>'+curDate+'</span>'+'<input type="button" value="删除"/></div></li>'))
            $('ul li:first').hide().slideDown() 
            $('textarea').val('')   
            console.log(new Date());
            
            $('li>div>input').on('click',function(){
                $(this).parents('li').remove();
            })
        })
        // 获取当前时间
        function getNowFormatDate() {
            var date = new Date();
            var seperator1 = "-";
            var seperator2 = ":";
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (strDate >= 0 && strDate <= 9) {
                strDate = "0" + strDate;
            }
            var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
            return currentdate;
        }
       
        
        
        
})